import babel from 'rollup-plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import alias from '@rollup/plugin-alias';
import modifyVars from './src/config/modifyVars';
import image from '@rollup/plugin-image';
// import { terser } from 'rollup-plugin-terser';
import path from 'path';

export default {
  input: 'src/components/index.js',
  output: [{ file: 'dist/index.js', format: 'esm' }],
  plugins: [
    postcss({
      extract: false,
      sourceMap: false,
      inject: true,
      extensions: ['.less', '.css'],
      use: {
        less: { javascriptEnabled: true, modifyVars },
      },
    }),
    babel({
      exclude: '**/node_modules/**',
      runtimeHelpers: true,
    }),
    resolve(),
    commonjs(),
    alias({
      entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
    }),
    image(),
    // terser(),
  ],
  external: ['prop-types', 'react', 'react-dom', 'ahooks', '@ant-design/icons'],
};
